$(document).ready(function () {
     // 评论时间
     function getPinglunTime(){
        var month=new Date().getMonth()+1
        month=month<10?'0'+month:month
        var day=new Date().getDate()
        day=day<10?'0'+day:day
        $('.pinglun-time').text(month+'-'+day+' 12:05')
    }
    getPinglunTime()
    $('.scroll-box').myScroll({
        speed: 60, //数值越大，速度越慢
        rowHeight: 65//li的高度
    });
    // 数字
    $('.numberStyle').leoTextAnimate({
        delay: 1000, //延时出现时间
        autorun: true, //是否自动运行
        fixed: [',', ':', '.'], //
        start: '0'
    });
    $('.content-left .list-box .title-list li').click(function(){
        let _index = $(this).index()
        $(this).addClass('active').siblings().removeClass('active')
        $('.content-left .content-list> ul>li').eq(_index).addClass('active').siblings().removeClass('active')
    })
//传播渠道
    function buildChart1() {
        var myChart = echarts.init(document.getElementById('index_1'));
        var title='今日总数'
        var sum=0
        option = {
            color: chartColor,
            title:{
                text: '{name|' + sum + '}\n{val|' + title + '}',
                top: 'center',
                left: 'center',
                textStyle: {
                    rich: {
                        name: {
                            fontSize: 26,
                            fontWeight: 'bold',
                            color: '#fff',
                            padding: [10, 0]
                        },
                        val: {
                            fontSize: 20,
                            fontWeight: 'normal',
                            color: '#fff',
                        }
                    }
                }
            },
            legend: {
                orient: 'vertical',
                top: '30%',
                right:'5%',
                itemWidth: 20,
                itemHeight: "10",
                data: ['微博', '微信', '网媒', '论坛', '视频', "APP"],
                textStyle: {
                    color: "#fff",
                    fontSize: 12
                }
            },
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            series: [
                {
                    name: '传播渠道',
                    type: 'pie',
                    radius: ['45%', '60%'],
                    center: ['50%', '50%'],
                    data: [
                        {value: 0, name: '微博'},
                        {value: 0, name: '微信'},
                        {value: 0,name: '网媒'},
                        {value: 0, name: '论坛'},
                        {value: 0, name: '视频'},
                        {value: 0, name: 'APP'}
                    ],
                    hoverAnimation: true,
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    },
                    itemStyle: {
                        normal: {
                            label: {
                                show: true,
//	                            position:'inside',
                                formatter: '{b} : {c} ({d}%)'
                            }
                        },
                        labelLine: {
                            normal:{
                                length:50,
                                length2:30
                            }
                        }
                    }
                }
            ]
        }
        myChart.setOption(option);
    }

//舆情趋势
    function buildChart2() {
        var myChart = echarts.init(document.getElementById('index_2'));
        let positiveDate = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]
        let negativeDate = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        let allDate = new Array
        for (let i = 0; i < positiveDate.length; i++) {
            allDate.push(positiveDate[i] + negativeDate[i])
        }
        option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    lineStyle: {
                        color: '#57617B'
                    }
                }
            },
            legend: {
                icon: 'rect',
                itemWidth: 14,
                itemHeight: 5,
                itemGap: 13,
                data: ['全部', '正面', '负面'],
                right: '4%',
                textStyle: {
                    fontSize: 12,
                    color: '#fff'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: [{
                type: 'category',
                boundaryGap: false,
                axisLine: {
                    lineStyle: {
                        color: '#57617B'
                    }
                },
                axisLabel: {
                    textStyle: {
                        fontSize: 12,
                        color: "#fff"
                    }
                },
                data: ['06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29']
            }, {
                axisPointer: {
                    show: false
                },
                axisLine: {
                    lineStyle: {
                        color: 'rgba(255,255,255,.2)'
                    }
                },
                axisTick: {
                    show: false
                },
                axisLabel: {
                    textStyle: {
                        fontSize: 12,
                        color: "#fff"
                    }
                },
                position: 'bottom',
                offset: 20,
            }],
            yAxis: [{
                type: 'value',
                axisTick: {
                    show: false
                },
                axisLine: {
                    lineStyle: {
                        color: 'rgba(255,255,255,.2)'
                    }
                },
                axisLabel: {
                    margin: 10,
                    textStyle: {
                        fontSize: 12,
                        color: "#fff"
                    }
                },
                splitLine: {
                    show: false
                }
            }],
            series: [{
                name: '全部',
                type: 'line',
                symbol: 'none',
                smooth: true,
                symbolSize: 5,
                showSymbol: false,
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(254, 89, 89, 0.6)'
                        }, {
                            offset: 0.3,
                            color: 'rgba(254, 89, 89, 0)'
                        }, {
                            offset: 1,
                            color: 'rgba(254, 89, 89, 0)'
                        }], false),
                    }
                },
                itemStyle: {
                    color: "rgba(254, 89, 89, 1)"
                },

                data: allDate
            }, {
                name: '正面',
                type: 'line',
                smooth: true,
                symbol: 'none',
                symbolSize: 5,
                showSymbol: false,
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(0, 228, 255, 0.6)'
                        }, {
                            offset: 0.3,
                            color: 'rgba(0, 228, 255,0)'
                        }, {
                            offset: 1,
                            color: 'rgba(0, 228, 255,0)'
                        }], false),
                    },
                },
                itemStyle: {
                    color: "rgba(0, 228, 255,1)"
                },
                data: positiveDate
            }, {
                name: '负面',
                type: 'line',
                symbol: 'none',
                smooth: true,
                symbolSize: 5,
                showSymbol: false,
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: ' rgba(83, 252, 179,0.6)'
                        }, {
                            offset: 0.3,
                            color: 'rgba(83, 252, 179,0)'
                        }, {
                            offset: 1,
                            color: 'rgba(83, 252, 179,0)'
                        }], false),
                    },
                },
                itemStyle: {
                    color: "rgba(83, 252, 179,1)"
                },

                data: negativeDate
            },]
        };
        myChart.setOption(option);
    }

    //正负面占比
    function buildChart3() {
        var myChart = echarts.init(document.getElementById('index_3'));
        option = {
            color: chartColor,

            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            series: [
                {
                    name: '正负面对比',
                    type: 'pie',
                    radius: '70%',
                    center: ['50%', '50%'],
                    data: [
                        {value: 0, name: '正面'},
                        {value: 0, name: '中性'},
                        {value: 0, name: '负面'}
                    ],
                    itemStyle: {
                        // color:["#14C6CA","#F29961"],
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    },
                    label: {
                        normal: {
                            position: 'inner',
                            formatter: '{b}' + '\n' + '{d}%',
                            textStyle: {
                                color: '#ffffff',
                                fontSize: 12
                            }
                        }
                    },
                },
            ]
        };
        myChart.setOption(option);
    }

//来源统计
    function buildChart4() {
        var myChart = echarts.init(document.getElementById('index_4'));
        option = {
            grid: {
                show: 'true',
                borderWidth: '0',
                height: "90%",
                width: "72%",
               left:'25%',
                bottom:'5%'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                },
                formatter: "{b0}: {c0}"
                /*formatter: function(params) {
                    var result = '';
                    params.forEach(function (item) {
                        result += item.marker + " " + item.seriesName + " : " + item.value +"</br>";
                    });
                    return result;
                }*/
            },
            xAxis: {
                show: false,                //是否显示x轴
                type: 'value'
            },
            yAxis: {
                type: 'category',
                inverse: true,               //让y轴数据逆向
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#666'       //y轴字体颜色
                    },
                    formatter: function (value, index) {
                        return [
                            '{lg|' + (index + 1) + '}' + '{title|' + value + '} '
                        ].join('\n');
                    },
                    //定义富文本标签
                    rich: {
                        lg: {
                            fontWeight: 'bold',
                            align: "left",
                            fontSize: 12,       //字体默认12
                            color: '#fff',
                            padding: [0, 5, 0, 0]
                        },
                        title: {
                            color: '#fff',
                            fontWeight: 'lighter',
                            // borderWidth: 1,
                            // borderColor: '#08c'
                            // textareaBorderColor: '#08c',
                        }
                    }
                },
                splitLine: {show: false},   //横向的线
                axisTick: {show: false},    //y轴的端点
                axisLine: {show: false},    //y轴的线
                data: ['微博', '微信', '网站', '新闻', '论坛', "视频", '报刊', '客户端', '博客', '外媒']
            },
            series: [
                {
                    name: '数据内框',
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                                offset: 0,
                                color: '#0489F0'
                            }, {
                                offset: 1,
                                color: '#28D8E8'
                            }]),
                            barBorderRadius: 50,
                        }
                    },
                    /*label: {
                        normal: {
                            show: true,
                            position: 'right',
                            color: 'red',
                            fontSize: 14,
                            formatter:
                            function(param) {
                                // return 'xx';
                            },
                        }
                    },*/
                    barWidth: 10,
                    data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]
                },
                {
                    name: '外框',
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            barBorderRadius: 10,
                            color: 'rgba(255, 255, 255, 0.14)' //rgba设置透明度0.14
                        }
                    },
                    barGap: '-100%',
                    z: 0,
                    barWidth: 10,
                    data: [2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000]
                }
            ]
        };
        myChart.setOption(option);
    }

//热门关键字
    function buildChart5() {
        var chart = echarts.init(document.getElementById('index_5'));

        var option = {
            tooltip: {},
            series: [{
                type: 'wordCloud',
                gridSize: 2,
                sizeRange: [12, 50],
                rotationRange: [-90, 90],
                shape: 'pentagon',
                width: 600,
                height: 400,
                drawOutOfBound: true,
                textStyle: {
                    normal: {
                        color: function () {
                            return 'rgb(' + [
                                Math.round(Math.random() * 160),
                                Math.round(Math.random() * 160),
                                Math.round(Math.random() * 160)
                            ].join(',') + ')';
                        }
                    },
                    emphasis: {
                        shadowBlur: 10,
                        shadowColor: '#333'
                    }
                },
                data: [
                    {
                        name: '八里沟',
                        value: 10000,
                        textStyle: {
                            normal: {
                                color: '#F29961'
                            },
                            emphasis: {
                                color: 'red'
                            }
                        }
                    },
                    {
                        name: '万仙山',
                        value: 6181
                    },
                    {
                        name: '九莲山',
                        value: 4386
                    },
                    {
                        name: '十一黄金周大堵车',
                        value: 4055
                    },
                    {
                        name: '环境整改何时能够落实',
                        value: 2467
                    },
                    {
                        name: '十一黄金周哪里玩',
                        value: 2244
                    },
                    {
                        name: '十一旅游需要防范什么',
                        value: 1898
                    },
                    {
                        name: '猪肉涨价',
                        value: 1484
                    },
                    {
                        name: '连锁反应',
                        value: 1112
                    },
                    {
                        name: '大阅兵',
                        value: 965
                    },
                    {
                        name: '高价打造A级景区',
                        value: 847
                    },
                    {
                        name: '景点',
                        value: 582
                    },
                    {
                        name: '不堪设想',
                        value: 555
                    },
                    {
                        name: '不堪设想',
                        value: 550
                    },
                    {
                        name: '交通运输',
                        value: 462
                    },
                    {
                        name: '交通堵塞',
                        value: 366
                    },
                    {
                        name: '宅',
                        value: 360
                    },
                    {
                        name: '大山',
                        value: 282
                    },
                    {
                        name: '青山绿水',
                        value: 273
                    },
                    {
                        name: 'BLACKPINK',
                        value: 265
                    }
                ]
            }]
        }

        chart.setOption(option);

        window.onresize = chart.resize;
    }
    // top10
    function buildChart0(){
        var chart = echarts.init(document.getElementById('index_0'));
        option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    lineStyle: {
                        color: '#57617B'
                    }
                }
            },
            yAxis: [{
                type: 'value',
                axisTick: {
                    show: false
                },
                axisLine: {
                    lineStyle: {
                        color: 'rgba(255,255,255,.2)'
                    }
                },
                axisLabel: {
                    margin: 10,
                    textStyle: {
                        fontSize: 12,
                        color: "#fff"
                    }
                },
                splitLine: {
                    show: false
                }
            }],
            xAxis: {
                type: 'category',
                axisLine: {
                    lineStyle: {
                        color: '#57617B'
                    }
                },
                axisLabel: {
                    textStyle: {
                        fontSize: 12,
                        color: "#fff"
                    }
                },
                data: ['快放了那女孩', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            },

            series: [{
                data: [120, 200, 150, 80, 70, 110, 130],
                type: 'bar',
                showBackground: true,
                backgroundStyle: {
                    color: 'rgba(220, 220, 220, 0.8)'
                }
            }]
        };
        chart.setOption(option);
    }
    setTimeout(buildChart1,800)
    setTimeout(buildChart2,1000)
    setTimeout(buildChart3,1200)
    setTimeout(buildChart4,1400)
    setTimeout(buildChart5,1600)
    buildChart0()
})
